window.onload=function(){
	
	var time= setInterval(Run,1000);
	var home = document.getElementsByClassName('img_list');
	home[0].onmouseover=function(){
		
		clearInterval(time);
	}
	home[0].onmouseleave=function(){
		time=setInterval(Run, 1000);
	}

	var img = document.getElementsByClassName('img');
	var click = document.getElementsByClassName('click');
	var num=0;
	var left =1;
	function Run(){
		
		for (var i = 0; i < img.length; i++) {
			img[i].style.display='none';
			click[i].style.backgroundColor='#000';
		}
		img[num].style.display='block';
		click[num].style.backgroundColor='#fff';

		if(num==img.length-1){
			num=0;
		}else {
			num++;
		}
		
	}
	

	for (var i = 0; i < click.length; i++) {
		click_change(i);

		}

	
	function click_change(i){
		click[i].onclick=function(){
			num=i;
			Run();
		}
	}

	var home_right=document.getElementsByClassName('home_right');
	home_right[0].onclick=function(){
		Run();
	}
	var home_left=document.getElementsByClassName('home_left');
	home_left[0].onclick=function(){
		
		
		if (num==1) {
			num=4;
		} else if(num==0){
			num=3;
		}
		else{
			num=num-2;
		};
		Run();

	}

	var shoppingcart =document.getElementsByClassName('shoppingcart');
	var shopping=document.getElementsByClassName('shopping');
	shopping[0].onmouseover=function(){
		shoppingcart[0].style.display='block';
	}
	shopping[0].onmouseleave=function(){
		shoppingcart[0].style.display='none';
	}
	
}